home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * @(#)hotsAccess.c 1.3 2/23/90
- */
-
- /*
- * $Header: /u1/Eden/Kernel/DataStructs/hotsAccess.c Revision 3.3 85/03/11 19:04:23 eric Exp$
- * INTERFACE: This module is used by invoking the functions listed
- * below in the EXPORTS column. The interface to each
- * procedure is described in the header comments of
- * the procedures themselves.
- * If the flag HOTSDBG is defined debug information is written
- * onto a file pointed to by stderr.
- * FUNCTION : Definition and operations on the data structure HOTS.
- * This module defines the data structure HOTS and implements
- * operations on it. The operations provided are: creating the
- * data structure, creating an entry, inserting an entry, searching
- * for an entry, replacing an entry, and deleting an entry.
- * IMPORTS : PrintTS, PrintEdenPort, PrintNodeStatus, PrintNodeCharacteristics,
- * PrintNodeNum, and PrintEtherNetAddress.
- * EXPORTS : CreateHOTSRecord HOTSCreate HOTSInsert HOTSSearch
- * HOTSSearchPtr HOTSReplace HOTSDelete PrintHOTSTable
- * PrintHOTS HOTSTraverse Whatisup HOTSDump
- * SNAPSHOTS: A snapshot called Whatisup which prints the HOTS table in
- * a nice format indicating which machines are up.
- * A snapshot to dump the table in a readable format (or just one
- * entry): HOTSDump
- * DESIGN : A hash table representation is used for representing the
- * structure. The hash table, HOTSTable, is organized as an
- * array containing pointers. Each entry in the table points
- * to the head of a list of records, HOTStr. A record (called
- * HOTSRecord) in HOTStr contains the actual HOTS information.
- * The records in a list are those which hash to the same value.
- * Hash function used: (LNN & 2**LOGSIZE-1), where LNN is a logical
- * node number.
- * The algorithms used for inserting, deleting, searching, and
- * replacing are standard list algorithms. The details are given
- * as comments with the individual procedures.
- * A one-item cache is used to improve efficiency.
- * TO DO : Should include the ability to search the structure for nodes
- * having certain characteristics.
- * $Log: /u1/Eden/Kernel/DataStructs/hotsAccess.c $
- * Revision 3.3 85/03/11 19:04:23 eric
- * Minor improvements to HOTS Dump.
- *
- * Revision 3.2 84/11/29 19:04:23 schwartz
- * Changed all calls to malloc so they don't call HoldSigs and ReleaseSigs
- * before and after, since this is now done in (Almes' version of) malloc.
- *
- * Revision 3.1 84/11/19 15:01:15 schwartz
- * Fixed KMD routines so they can print the names of any physical host, and
- * so they know about NodeCharacteristics IsBrdcstProcess and IsEFTServer,
- * and so that they correctly determine the default Nodes.
- *
- * Revision 3.0 84/07/04 00:04:02 schwartz
- * Changes for port of Eden to Sun workstations.
- *
- * Revision 2.2 84/02/17 14:53:21 eric
- * Fixed HOTSTraverse so that it responds correctly when HOTS table
- * has not been initialized.
- *
- * Revision 2.1 84/02/16 22:02:19 oystr
- * Version 2 baseline.
- *
- * Revision 1.10 84/02/16 13:46:16 eric
- * Major revision of the Message Module requiring introduction of new
- * fields on a per node basis in the HOTS table.
- *
- * Revision 1.7 83/12/01 16:47:12 eric
- * HOTSTraverse routine added by Jan Sanislo.
- * It may be used to sequentially traverse the entries in the table.
- *
- * Revision 1.6 83/08/07 20:40:31 venkat
- * included decrementing NoHOTSEntries when a HOTS entry is deleted.
- *
- * Revision 1.5 83/03/15 11:52:11 venkat
- * Added a new function HOTSSearchPtr to return a pointer to a located HOTSRecord.
- *
- * Revision 1.4 83/02/25 11:55:20 venkat
- * PrintHOTSTable and PrintHOTS now return KKStatus.
- *
- * Revision 1.3 83/01/26 11:51:29 venkat
- * Changed the type of the argument for CreateHOTSRecord to a pointer to the
- * pointer of a HOTSRecord.
- *
- * Revision 1.2 83/01/08 11:50:57 venkat
- * HOTSTable has now been declared as an array of size HOTSIZE instead of
- * HOTSLIMIT - 1.
- *
- * Revision 1.1 83/01/04 15:16:41 venkat
- * Initial revision
- *
- *
- */
-
-
- #include <stdio.h>
- #include "Kernel/h/system.h"
- #include "Kernel/h/mmTypes.h"
- #include "Kernel/h/stdTypes.h"
- #include "Kernel/h/dstCodes.h"
- #include "Kernel/h/hotsTypes.h"
- #include "Kernel/h/edenBaseTime.h"
- #include "Kernel/h/kEvents.h"
- #include "Kernel/h/kmdTypes.h"
-
- /* Forward declaration of snapshots and traces. */
- void SnapHOTSElem(), HOTSDump(), Whatisup();
-
-
-
- /* For printing Nodestatus: */
- #define NSStatus(x) x == Dead ? "Dead" : x == Alive ? "Alive" : \
- x == Deaf ? "Deaf" : x == Dumb ? "Dumb" : x == Booting ? "Booting" : \
- "Unknown status"
-
- #define HOTSLAST 255 /* Must be HOTSIZE - 1 (addr of last) */
- #define HOTSLIMIT 250 /* Maximum number of HOTS entries */
- #define HashValue(lnn) (lnn & HOTSLAST)
-
- /*Hash table as an array of pointers*/
- struct HOTStr *HOTSTable[HOTSIZE];
-
- int NoHOTSEntries; /*No. of entries in the HOTS table*/
- Boolean initflag = False; /*Has HOTSCreate been called yet?*/
- static NodeNum CacheLNN = 0; /*Cached LNN no. */
- static HOTSRecord *CachePtr; /*Cached pointer.*/
- char *malloc(); /*C function to allocate storage */
-
- extern PrintEdenPort(), PrintTS(), PrintNodeStatus(), PrintNodeCharacteristics();
- extern PrintNodeNum(), PrintEtherNetAddress();
-
- KKStatus InsertInTable(), PrintHOTSTable(), PrintHOTS();
- KKStatus HOTSInsert(),HOTSCreate(),HOTSSearch(),HOTSReplace(),HOTSDelete();
- struct HOTStr *LookUp();
-
- /*
- * RETURNS : KKStatus
- * EFFECT : Initializes HOTSTable, by setting the number of entries to
- * 0 and the entries to NULL. Also, sets the flag, initflag,
- * which is used by the other exported functions to check
- * whether they are called without creating the HOTS table.
- * DEFICIENCIES: Have not included any check to see whether sufficient memory
- * is available.
- * INTERFACE : HOTSCreate()
- */
-
-
- KKStatus HOTSCreate()
- {
- int i;
-
- #ifdef HOTSDBG
- printf("entering HOTSCreate\n");
- #endif
-
- NoHOTSEntries = 0;
- CacheLNN = 0;
-
- /*Initialize HOTSTable: set entries to null*/
- for (i = 0; i <= HOTSLAST; ++i)
- HOTSTable[i] = NULL;
-
- initflag = True;
-
- /* Set snapshots. */
- KMDSetSnap(HOTSDump);
- KMDSetSnap(Whatisup);
-
- #ifdef HOTSDBG
- printf("returning from HOTSCreate\n");
- #endif
-
- return(DSTS_Success);
- }
-
-
- /*
- * OUT : fNewRecord, a pointer to HOTSRecord
- * RETURNS : KKStatus
- * EFFECT : Creates a HOTSRecord entry and returns a pointer to it
- * in fNewRecord.
- * DEFICIENCIES: For now only storage is allocated for a HOTSRecord entry
- * and it is upto the caller to fill in the entries of the
- * HOTSRecord structure.
- * INTERFACE : CreateHOTSRecord(fNewRecord)
- * fNewRecord is a pointer to a pointer of HOTSRecord.
- */
-
- KKStatus CreateHOTSRecord(fNewRecord)
- HOTSRecord **fNewRecord;
- {
- (*fNewRecord) = (HOTSRecord *) malloc(sizeof(HOTSRecord));
- if ((*fNewRecord) == NULL)
- return(DSTK_NoMemory);
- else
- return(DSTS_Success);
- }
-
-
- /*
- * IN : fNewNode
- * RETURNS : KKStatus
- * EFFECT : To insert a HOTSRecord entry into the hash table. The entry
- * is inserted if it is not a duplicate and does not cause
- * table overflow. Invokes function InsertInTable to check for
- * duplicates and to insert if the given LNN is not a duplicate.
- * The LNN pointed to by fNewNode is hashed to get a table
- * index. This gives a pointer to a list of HOTSRecord entries.
- * If fNewNode does not already exist in the list then it is
- * inserted at the head of the list.
- * INTERFACE : HOTSInsert(fNewNode)
- * fNewNode is a pointer to the HOTSRecord structure.
- */
-
- KKStatus HOTSInsert(fNewNode)
- HOTSRecord fNewNode;
- {
- KKStatus status;
-
- #ifdef HOTSDBG
- printf("entered HOTSInsert\n");
- #endif
-
- if (initflag) {
-
- /*Check for overflow. If no overflow try to insert in table*/
- if (NoHOTSEntries <= HOTSLIMIT) /*No overflow*/ {
- status = InsertInTable(fNewNode, HashValue(fNewNode.LNN));
- if (status == DSTS_Success) {
-
- /*Update entries in table*/
- NoHOTSEntries += 1;
-
- #ifdef HOTSDBG
- printf( "inserted node no. %d NoHOTSEntries = %d\n", fNewNode.LNN, NoHOTSEntries);
- #endif
- }
- /*status obtained from InsertInTable returned*/
- return(status);
- }
- else /*overflow*/ {
-
- #ifdef HOTSDBG
- printf( "table overflow\n");
- #endif
-
- return(DSTF_HOTSOvFlow);
- }
- }
- else /*data structure not initialized*/ {
-
- #ifdef HOTSDBG
- printf( "HOTSCreate has not been called to create the HOTS table\n");
- #endif
- return(DSTF_DSNotCreated);
- }
- }
-
-
-
- /*
- * IN : fNewEntry, fIndex
- * RETURNS : KKStatus
- * EFFECT : If entry is not in table adds as the first element in the
- * chain of elements having the same hash value as this one.
- * Searches for fNewEntry in the list pointed to by the table
- * entry whose index is given by fIndex.
- * If not found then adds it as the first entry in the list.
- * INTERFACE : InsertInTable(fNewEntry, fIndex)
- * fNewEntry is of type HOTSRecord and fIndex is an integer.
- */
-
- static KKStatus InsertInTable(fNewEntry,fIndex)
- HOTSRecord fNewEntry;
- int fIndex;
- {
- struct HOTStr *np;
-
- if ((np = LookUp(fNewEntry.LNN,fIndex)) == NULL) {
-
- /*entry not in table. add it as first element in its chain*/
-
- #ifdef HOTSDBG
- printf( "Entry not in table. Add it as first element\n");
- #endif
- np = (struct HOTStr *) malloc(sizeof(struct HOTStr));
- if (np != NULL) {
- np -> ThisEntry = fNewEntry;
- np -> next = HOTSTable[fIndex];
- HOTSTable[fIndex] = np;
- #ifdef HOTSDBG
- printf( "New entry (%d, x%08x)\n", fNewEntry.LNN,
- &np -> ThisEntry);
- #endif
- return(DSTS_Success);
- }
- else /*not enough memory got from malloc*/
- return(DSTK_NoMemory);
- }
- else /*entry in table*/ {
-
- #ifdef HOTSDBG
- printf("entry in table already-returning\n");
- #endif
-
- return(DSTF_HOTSDupID);
- }
- }
-
-
-
-
- /*
- * IN : fNewLNN, fIndex
- * RETURNS : A pointer to HOTStr if there is an entry for fNewUID and
- * NULL otherwise.
- * EFFECT : Checks whether an entry for fNewLNN exists in the list
- * pointed to by the table entry given by fIndex. If so,
- * a pointer to that entry is returned. If not, returns
- * NULL.
- * INTERFACE : LookUp(fNewLNN, fIndex)
- * fNewLNN is of type NodeNum and fIndex is an integer.
- */
-
- static struct HOTStr *LookUp(fNewLNN, fIndex)
- NodeNum fNewLNN;
- int fIndex;
- {
- struct HOTStr *np;
-
- /*search the chain emanating from table[index]*/
- for (np = HOTSTable[fIndex]; np != NULL; np = np -> next)
- if (fNewLNN == np -> ThisEntry.LNN)
- return(np);
-
- /*Entry not in the list*/
- return(NULL); /*not found*/
- }
-
-
-
- /*
- * IN : fThisLNN
- * RETURNS : The hash value of the given node number
- * INTERFACE: HashValue(fThisLNN)
- * fThisLNN is of type NodeNum
- */
- /* Defined as a macro.
- static int HashValue(fThisLNN)
- NodeNum fThisLNN;
- {
- return( fThisLNN & HOTSLAST );
- }
- */
-
- /*
- * IN : fQueryLNN, fEntry
- * OUT : fEntry points to the HOTSRecord of fQueryLNN, if such
- * a HOTSRecord exists.
- * RETURNS : KKStatus
- * EFFECT : Searches the table for a HOTSRecord entry for the given LNN. If
- * found then a pointer to the HOTSRecord is stored in fEntry.
- * In that case KKStatus is set to DSTS_Success. If there is no
- * HOTSRecord entry for the given LNN then KKStatus is set to
- * DSTF_HOTSSearchNoEntry.
- * INTERFACE: HOTSSearch(fQueryLNN, fEntry)
- * fQueryLNN is of type NodeNum and fEntry is a pointer to
- * HOTSRecord.
- */
-
- KKStatus HOTSSearch(fQueryLNN, fEntry)
- NodeNum fQueryLNN;
- HOTSRecord *fEntry;
- {
- int index;
- struct HOTStr *ThisStr;
-
- #ifdef HOTSDBG
- printf("entering HOTSSearch\n");
- #endif
- if (initflag) {
- index = HashValue(fQueryLNN);
-
- if (HOTSTable[index] == NULL) /*no chain*/ {
-
- #ifdef HOTSDBG
- printf( "no entry in table - returning\n");
- #endif
-
- return(DSTF_HOTSSearchNoEntry);
- }
- else /*there is atleast one entry in the chain*/ {
- ThisStr = LookUp(fQueryLNN, index);
- if (ThisStr == NULL) /*given LNN not in chain*/ {
-
- #ifdef HOTSDBG
- printf( "no entry in table - returning\n");
- #endif
- return(DSTF_HOTSSearchNoEntry);
- }
- else /*given LNN in chain. Get entry into fEntry*/ {
- (*fEntry) = ThisStr -> ThisEntry;
-
- #ifdef HOTSDBG
- printf("got the entry (%d, x%08x) - returning\n", (*fEntry).LNN,
- &ThisStr->ThisEntry);
- #endif
-
- return(DSTS_Success);
- }
- }
- }
- else /*data structure not initialized*/ {
-
- #ifdef HOTSDBG
- printf( "HOTSCreate has not been called to create the HOTS table\n");
- #endif
- return(DSTF_DSNotCreated);
- }
- }
-
-
-
- /*
- * IN : fQueryLNN, fEntryPtr
- * OUT : fEntryPtr points to the HOTSRecord of fQueryLNN, if such
- * a HOTSRecord exists.
- * RETURNS : KKStatus
- * EFFECT : Searches the table for a HOTSRecord entry for the given LNN. If
- * found then a pointer to the address of the HOTSRecord is stored
- * in fEntryPtr. In that case KKStatus is set to DSTS_Success.
- * If there is no HOTSRecord entry for the given LNN then KKStatus
- * is set to DSTF_HOTSSearchNoEntry.
- * INTERFACE: HOTSSearchPtr(fQueryLNN, fEntryPtr)
- * fQueryLNN is of type NodeNum and fEntryPtr is a pointer to
- * a HOTSRecord pointer.
- */
-
- KKStatus HOTSSearchPtr(fQueryLNN, fEntryPtr)
- NodeNum fQueryLNN;
- HOTSRecord **fEntryPtr;
- {
- int index;
- struct HOTStr *ThisStr;
-
- #ifdef HOTSDBG
- printf(">HOTSSearchPtr(%d, x)\n", fQueryLNN);
- #endif
-
- /* Check Cache. */
- if ((fQueryLNN == CacheLNN) && CacheLNN) {
- /* Cache hit. */
- (*fEntryPtr) = CachePtr;
- #ifdef HOTSDBG
- printf( " Cache hit (%d, x%08x)\n",
- CacheLNN, (*fEntryPtr));
- #endif
- return DSTS_Success;
- };
-
- if (initflag) {
- index = HashValue(fQueryLNN);
-
- if (HOTSTable[index] == NULL) /*no chain*/ {
-
- #ifdef HOTSDBG
- printf( "no entry in table - returning\n");
- #endif
-
- return(DSTF_HOTSSearchNoEntry);
- }
- else /*there is atleast one entry in the chain*/ {
- ThisStr = LookUp(fQueryLNN, index);
- if (ThisStr == NULL) /*given LNN not in chain*/ {
-
- #ifdef HOTSDBG
- printf( "no entry in table - returning\n");
- #endif
- return(DSTF_HOTSSearchNoEntry);
- }
- else /*given LNN in chain. Get entry into fEntryPtr*/ {
- CachePtr = (*fEntryPtr) = &ThisStr -> ThisEntry;
- CacheLNN = fQueryLNN;
-
- #ifdef HOTSDBG
- printf("got the entry (%d, x%08x) - returning\n", CacheLNN,
- CachePtr);
- #endif
-
- return(DSTS_Success);
- }
- }
- }
- else /*data structure not initialized*/ {
-
- #ifdef HOTSDBG
- printf( "HOTSCreate has not been called to create the HOTS table\n");
- #endif
- return(DSTF_DSNotCreated);
- }
- }
-
- /***********************************************************************
- * Traverse the HOTS table. *
- ***********************************************************************/
-
-
- HOTSRecord *HOTSTraverse( fIndex, fEntry)
- integer *fIndex;
- struct HOTStr **fEntry;
- {
- register int index;
- register struct HOTStr *entry;
-
- if (! initflag) {
- *fEntry = NULL;
- return ( NULL );
- };
-
- index = *fIndex;
- if ( (entry = *fEntry) != NULL )
- entry = entry->next;
- if ( entry == NULL )
- for ( index = index+1; index < HOTSIZE; index++ )
- if ( (entry = HOTSTable[index]) != NULL )
- break;
- if ( entry == NULL ) {
- return ( NULL );
- }
- else
- { *fIndex = index;
- *fEntry = entry;
- return ( &entry->ThisEntry );
- }
- }
-
-
-
- /*
- * IN : fNewData
- * RETURNS : KKSTATUS
- * EFFECT : The HOTSRecord entry in the table for the LNN in fNewData is
- * replaced. If no entry exists for the given LNN then KKStatus
- * is set to DSTF_HOTSReplaceNoEntry.
- * INTERFACE: HOTSReplace(fNewData)
- * Here fNewData is of type HOTSRecord.
- */
-
- KKStatus HOTSReplace(fNewData)
- HOTSRecord fNewData;
- {
- int index;
- struct HOTStr *ThisStr;
-
- #ifdef HOTSDBG
- printf( "entering HOTSReplace\n");
- #endif
- /* Invalidate cache. */
- CacheLNN = 0;
- if (initflag) {
- index = HashValue(fNewData.LNN);
- if (HOTSTable[index] == NULL) /*no chain*/ {
-
- #ifdef HOTSDBG
- printf( "entry not in table - returning\n");
- #endif
-
- return(DSTF_HOTSReplaceNoEntry);
- }
- else /*there is at least one entry in the chain*/ {
- ThisStr = LookUp(fNewData.LNN, index);
- if (ThisStr == NULL) /*given LNN not in chain*/ {
-
- #ifdef HOTSDBG
- printf( "entry not in table - returning\n");
- #endif
-
- return(DSTF_HOTSReplaceNoEntry);
- }
- else /*given LNN in chain. replace entry by fNewData*/ {
- ThisStr -> ThisEntry = fNewData;
-
- #ifdef HOTSDBG
- printf("replaced entry - returning\n");
- #endif
-
- return(DSTS_Success);
- }
- }
- }
- else /*data structure not initialized*/ {
-
- #ifdef HOTSDBG
- printf( "HOTSCreate has not been called to create the HOTS table\n");
- #endif
- return(DSTF_DSNotCreated);
- }
- }
-
-
-
- /*
- * IN : fLNN
- * RETURNS : KKSTATUS
- * EFFECT : Deletes the HOTSRecord entry associated with fLNN from the table.
- * INTERFACE : HOTSDelete(fLNN)
- * fLNN is of type NodeNum
- */
-
- KKStatus HOTSDelete(fLNN)
- NodeNum fLNN;
- {
- int index;
- struct HOTStr *prev, *crnt;
-
- #ifdef HOTSDBG
- printf( "entering HOTSDelete\n");
- #endif
- /* Invalidate Cache */
- CacheLNN = 0;
- if (initflag) {
- index = HashValue(fLNN);
-
- if (HOTSTable[index] == NULL) /*no chain*/ {
-
- #ifdef HOTSDBG
- printf( "entry not in table - returning\n");
- #endif
-
- return(DSTF_HOTSDeleteNoEntry);
- }
- else /*there is atleast one entry in the chain*/
- if (HOTSTable[index] -> ThisEntry.LNN == fLNN) {
-
- #ifdef HOTSDBG
- printf( "the first entry in the chain to be deleted");
- #endif
-
- /*the first entry in the chain to be deleted*/
- crnt = HOTSTable[index];
- HOTSTable[index] = HOTSTable[index] -> next;
- free((char *)crnt);
-
- #ifdef HOTSDBG
- printf( " - returning after deleting\n");
- #endif
-
- NoHOTSEntries--;
- return(DSTS_Success);
- }
- else {
-
- /*the first entry does not match. Check other entries in chain*/
- prev = HOTSTable[index];
- for (crnt = HOTSTable[index] -> next; crnt != NULL;
- prev = crnt, crnt = crnt -> next)
- if (crnt -> ThisEntry.LNN == fLNN) {
-
- /*this entry to be deleted; release storage*/
- prev -> next = crnt -> next;
- free((char *)crnt);
-
- #ifdef HOTSDBG
- printf("located and deleted the entry - returning\n");
- #endif
-
- NoHOTSEntries--;
- return(DSTS_Success);
- }
-
- #ifdef HOTSDBG
- printf( "the entry not present - returning\n");
- #endif
-
- return(DSTF_HOTSDeleteNoEntry);
- }
- }
- else /*data structure not initialized*/ {
-
- #ifdef HOTSDBG
- printf( "HOTSCreate has not been called to create the HOTS table\n");
- #endif
- return(DSTF_DSNotCreated);
- }
- }
-
- #ifdef xxxPRINTHOTSTABLExxx
- /*
- * IN : fFile
- * RETURNS : KKStatus
- * EFFECT : Writes all the HOTS records in the HOTS table onto the file
- * pointed to by fFile.
- * INTERFACE : PrintHOTSTable(fFile)
- * fFile is a file pointer.
- */
- KKStatus PrintHOTSTable(fFile)
- FILE *fFile;
- {
- int i;
- if (initflag) {
- #ifdef xsimul
- fprintf(fFile, "The contents of the HOTS table:\n");
- for (i = 0; i < HOTSIZE; i++)
- if (HOTSTable[i] != NULL)
- PrintHOTStr(fFile, HOTSTable[i]);
- #else
- printf("unix would print HOTS table to a file here\n")
- #endif
- return(DSTS_Success);
- } else { /*HOTS table not initialized*/
-
- #ifdef HOTSDBG
- printf( "HOTSCreate has not been called to create the HOTS table\n");
- #endif
- return(DSTF_DSNotCreated);
- }
- }
-
-
- /*
- * IN : fFile, fHOTStr
- * EFFECT : Writes all the HOTSRecords which hashed to the same index onto
- * the file pointed to by fFile.
- * INTERFACE : PrintHOTStr(fFile, fHOTStr)
- * fFile is a file pointer and fHOTStr is a pointer to HOTStr.
- */
- static PrintHOTStr(fFile, fHOTStr)
- FILE *fFile;
- struct HOTStr *fHOTStr;
- {
- register struct HOTStr *np;
- #ifdef xsimul
- for (np = fHOTStr; np != NULL; np = np -> next)
- PrintHOTS(fFile, np -> ThisEntry);
- #endif
- }
-
-
-
- /*
- * IN : fFile, fHR
- * RETURNS : KKStatus
- * EFFECT : Writes entries of a given HOTSRecord onto the file pointed
- * to by fFile.
- * DEFICIENCIES : Not all entries of the HOTS record are written out.
- * INTERFACE : PrintHOTS(fFile, fHR)
- * fFile is a file pointer and fHR is of type HOTSRecord
- */
- KKStatus PrintHOTS(fFile, fHR)
- FILE *fFile;
- HOTSRecord fHR;
- {
- #ifdef xsimul
- fprintf(fFile, " Logical node number : ");
- PrintNodeNum(fFile, fHR.LNN);
- fprintf(fFile, " EtherNetAddress : ");
- PrintEtherNetAddress(fFile, fHR.EtherAddr);
- fprintf(fFile, " NodeStatus : ");
- PrintNodeStatus(fFile, fHR.NodeStat);
- fprintf(fFile, " Last Message TimeStamp : ");
- PrintTS(fFile, fHR.LastMsgTs);
- fprintf(fFile, " Node Characteristics as a 32-bit integer : ");
- PrintNodeCharacteristics(fFile, fHR.NodeCharac);
- if (fHR.NodeIsLocal)
- fprintf(fFile, " Local\n");
- else
- fprintf(fFile, " Not local\n");
- fprintf(fFile, " Port = ");
- PrintEdenPort(fFile, fHR.NodeNetPort);
- fprintf(fFile,
- "AckExp NxtTSend NxtSeqNo LatestAck MsgExp TooFar\n");
- fprintf(fFile, "%5d %9d %9d %9d %9d %9d\n", fHR.AckExpected,
- fHR.NextMsgToSend, fHR.NextSeqNo, fHR.LatestAck, fHR.MsgExpected,
- fHR.TooFar);
- fprintf(fFile, "SWSize = %d, OutOfOrder Count = %d\n",
- fHR.SendWindowSize, fHR.OutOfOrderCount);
- if (fHR.Timed)
- fprintf(fFile, "Timed AckTimer = %d, MsgTimer = %d",
- fHR.AckTimerCount, fHR.MsgTimerCount);
- else
- fprintf(fFile, "Not Timed.");
- if (fHR.NakSent)
- fprintf(fFile, " NAK has been sent.\n");
- else
- fprintf(fFile, " No NAK has been sent.\n");
- fprintf(fFile, "ToSendPtr %08x SentPtr %08x\n", fHR.ToSendPtr,
- fHR.SentPtr);
- fprintf(fFile, "Statistics\n");
- fprintf(fFile,
- "ReTran NAKSen NAKRcv MsgDrp ACKSen ACKRcv MsgDlv MsgAcp\n");
- fprintf(fFile, "%5d %6d %6d %6d %6d %6d %6d %6d\n", fHR.RetransCount,
- fHR.NAKsSent, fHR.NAKsRecv, fHR.MsgDropped, fHR.ACKsSent,
- fHR.ACKsRecv, fHR.MsgDelivered, fHR.MsgAccepted);
- fprintf(fFile, "\n\n");
- (void) fflush(fFile);
- #endif
- return(DSTS_Success);
- }
-
- #endif xxxPRINTHOTSTABLExxx
-
-
- /* Snapshot auxiliarry procedure to print a single entry. */
-
- void SnapHOTSElem(fHR)
- HOTSRecord fHR;
- {
- KMDPrint("Logical node number : %3d of %.15s %s\n", (int) fHR.LNN,
- 4+ctime(&fHR.NodeIncarnationId), NSStatus(fHR.NodeStat));
- KMDPrint("EtherNetAddress : %s %-7.7s at %-8.8s\n",
- inet_ntoa(fHR.EtherAddr.sin_addr),
- fHR.NodeIsLocal ? "Local" : "Remote",
- mGetHostName(&(fHR.EtherAddr)));
- KMDPrint("Last Msg Time : %-24.24s.\n", ctime(&fHR.LastMsgTs));
- /* KMDPrint("Node Characteristics: 0x%08x (%s)\n",
- fHR.NodeCharac, NodeKind(&fHR) ); */
- KMDPrint(
- "AckExp NxtTSend NxtSeqNo LatestAck MsgExp TooFar\n");
- KMDPrint("%5d %9d %9d %9d %9d %9d\n", fHR.AckExpected,
- fHR.NextMsgToSend, fHR.NextSeqNo, fHR.LatestAck, fHR.MsgExpected,
- fHR.TooFar);
- KMDPrint("SendWindowSize %2d, OutOfOrder %d, %sNAK sent\n",
- fHR.SendWindowSize, fHR.OutOfOrderCount, fHR.NakSent ? "" : "No ");
- if (fHR.Timed)
- KMDPrint("Timed AckTimer = %d ticks, MsgTimer = %d ticks.\n",
- fHR.AckTimerCount, fHR.MsgTimerCount);
- else
- KMDPrint("No activity pending - not timed.\n");
- KMDPrint("First flow-controlled msg %s been sent from me to this node.\n",
- fHR.FirstFCMsgSent ? "has" : "has not");
- if (fHR.FirstFCMsgSent) {
- KMDPrint("FCM sent, ToSendPtr %08x SentPtr %08x\n", fHR.ToSendPtr,
- fHR.SentPtr);
- } else KMDPrint("No message sent to this node.\n");
- KMDPrint("Statistics for Ethernet communication protocol\n");
- KMDPrint("ReTran NAKSen NAKRcv MsgDrp ACKSen ACKRcv MsgDlv MsgAcp\n");
- KMDPrint("%5d %6d %6d %6d %6d %6d %6d %6d\n", fHR.RetransCount,
- fHR.NAKsSent, fHR.NAKsRecv, fHR.MsgDropped, fHR.ACKsSent,
- fHR.ACKsRecv, fHR.MsgDelivered, fHR.MsgAccepted);
- KMDPrint("\n");
- }
-
-
- /* Snapshot routine to dump the HOTS table in a readable format. */
- /* If given a non-zero parameter only the specified table entry is */
- /* printed. */
- /* Eric Jul, 1984-05-20 */
-
- void HOTSDump(fLNN)
- int fLNN;
- {
- int i;
- register struct HOTStr *np;
- time_t theTime;
-
- theTime = time((time_t *) 0);
-
- KMDPrint("Dump of HOTS Table residing in LNN %d at %s\n", GetLNN(),
- ctime(&theTime));
-
- for (i=0; i < HOTSIZE; i++)
- for(np = HOTSTable[i]; np != NULL; np = np -> next)
- if ( (! fLNN) || (fLNN == np->ThisEntry.LNN) )
- SnapHOTSElem(np -> ThisEntry);
- }
-
-
- /* Prints the HOTS table in a one line per entry format. */
-
- void Whatisup()
- {
- register int i;
- register struct HOTStr *np;
- time_t theTime = time((time_t *) 0);
- time_t tmp;
- char incarnationTimeString[20];
-
- KMDPrint("Emerald network according to node %d on %s", GetLNN(),
- ctime(&theTime));
- KMDPrint(" LNN Incarnation Physical State Last state change\n");
- KMDPrint(" ---------------------------------------------------------------\n");
-
- for (i=0; i < HOTSIZE; i++)
- for(np = HOTSTable[i]; np != NULL; np = np -> next) {
- tmp = np->ThisEntry.LastMsgTs;
- (void) sprintf(incarnationTimeString, "%.15s",
- 4+ctime(&np->ThisEntry.NodeIncarnationId));
- KMDPrint("%4d %.15s %-11.11s %-8.8s %-15.15s\n",
- np->ThisEntry.LNN,
- incarnationTimeString,
- mGetHostName(&(np->ThisEntry.EtherAddr)),
- NSStatus(np->ThisEntry.NodeStat),
- 4+ctime(&tmp));
- }
- }
-